package com.mate.cloud.message.controller;

import com.mate.cloud.common.response.BaseResponse;
import com.mate.cloud.common.web.controller.AdminBaseController;
import com.mate.cloud.message.service.PhoneService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 短信验证码
 *
 * @author: MI
 * @email: 448341911@qq.com
 * @createTime: 2024/5/24 19:08
 * @updateUser: MI
 * @updateTime: 2024/5/24 19:08
 * @updateRemark: 修改内容
 * @version: v1.0
 */
@RestController
@RequestMapping("/code")
public class PhoneController extends AdminBaseController {


    @Resource
    private PhoneService phoneService;

    @GetMapping("/send")
    public BaseResponse send(@RequestParam("phone") String phone) {
        return successBodyResponse(phoneService.sendMessage(phone));
    }

    @GetMapping("/check")
    public BaseResponse check(@RequestParam("phone") String phone, @RequestParam("code") String code) {
        return successBodyResponse(phoneService.check(phone, code));
    }

    /**
     * 抛出异常演示
     *
     * @return
     */
    @GetMapping("/exceptionThrow")
    public BaseResponse exceptionThrow() {
        phoneService.exceptionThrow();
        return successCodeResponse();
    }

}
